#pragma once

#include <iostream>
#include <queue>
#include <cstdlib>


template <typename E>  // E is the element type.
class Queue {
public:
    Queue() {
        std::cout << "construct " << ++times << "times" << std::endl;
    }
    void Enqueue(const E element) {
        E* e = new E;
        *e = element;
        items.push(e);
    }

    E* Dequeue() {  // Returns NULL if the queue is empty.
        if (items.empty()) {
            return nullptr;
        }
        auto e = items.front();
        items.pop();
        return e;
    }

    size_t size() const {
        return items.size();
    }
private:
    std::queue<E*> items;
    static uint times;
};

template <typename E>  // E is the element type.
uint Queue<E>::times = 0;

